import 'package:lishopflu/base/base_page.dart';
import 'package:lishopflu/base/controller_import.dart';
import 'package:lishopflu/base/view_import.dart';
import 'package:lishopflu/entity/address_bean.dart';
import 'package:lishopflu/router/app_navigator.dart';

import 'order_confirm_ctl.dart';

class OrderConfirmPage extends BasePage<OrderConfirmCtl>{


  @override
  void onCreate(BuildContext mContext) {
    setAppTitle('确认订单');
  }

  @override
  Widget pageBody(BuildContext context) {
    return Container(
      child: Column(
        children: [
          Expanded(
            flex: 1,
            child: SingleChildScrollView(
              scrollDirection: Axis.vertical,
              child: Column(
                children: [
                  addressWidget(),
                  orderWidget(),
                ],
              ),
            ),
          ),
          Container(
            padding: EdgeInsets.only(left: 10, right: 10, bottom: 10),
            color: Colors.white,
            child: Row(
              children: [
                Padding(
                  child: Text('￥10.85', style: TextStyle(color: Colors.red, fontSize: 18, fontWeight: FontWeight.bold),),
                  padding: EdgeInsets.all(8),
                ),
                Expanded(
                  flex: 1,
                  child: MaterialButton(
                    child: Text('支付订单', style: TextStyle(fontSize: 14, color: Colors.white,),),
                    color: Colors.blueAccent,
                    padding: EdgeInsets.only(top: 8, bottom: 8),
                    shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
                    onPressed: (){

                    },
                  ),
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }

  /*
   * 地址信息
   */
  Widget addressWidget(){
    return GestureDetector(
      onTap: (){
        controller.toAddressChoose();
      },
      child: Container(
        child: Row(
          children: [
            Expanded(
              flex: 1,
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Row(
                    children: [
                      Padding(
                        padding: EdgeInsets.only(left: 15, right: 15, top: 5, bottom: 5),
                        child: Obx(() => Text(controller.addressBean.value.name, style: TextStyle(fontWeight: FontWeight.bold),),),
                      ),
                      Obx(() => Text(StringUtil.text(controller.addressBean.value.phone),),),
                    ],
                  ),
                  Padding(
                    padding: EdgeInsets.only(left: 15, right: 15, top: 5, bottom: 5),
                    child: Obx(() => Text(controller.addressBean.value.address),),
                  ),
                ],
              ),
            ),
            CommonWidget.icon(),
          ],
        ),
        decoration: CommonWidget.boxWhite(),
        margin: EdgeInsets.all(10),
        padding: EdgeInsets.all(10),
        width: double.infinity,
      ),
    );
  }

  /*
   * 地址信息
   */
  Widget orderWidget(){
    return Container(
      child: Column(
        children: [
          Obx(() => Text('productId:${controller.productId.value}'),),
        ],
      ),
      decoration: CommonWidget.boxWhite(),
      margin: EdgeInsets.all(10),
      padding: EdgeInsets.all(10),
      width: double.infinity,
    );
  }

}